﻿using SqlSugar;

namespace PublicModels;

/// <summary>
/// 用户
/// </summary>
[SugarTable("Users")]
public class User
{
    public User()
    {

    }

    public User(User user)
    {
        Account = user.Account;
        Password = user.Password;
        Username = user.Username;
    }

    public User(int account, string password, string username)
    {
        Account = account;
        Password = password;
        Username = username;
    }

    public User(int account, string password)
    {
        Password = password;
        Account = account;
    }

    public User(string username, string password)
    {
        Password = password;
        Username = username;
    }

    [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
    public int Account { get; set; }

    private string password = string.Empty;
    public string Password
    {
        get { return password; }
        set { password = value.Trim(); }
    }


    private string username = string.Empty;
    public string Username
    {
        get { return username; }
        set { username = value.Trim(); }
    }

    public override bool Equals(object? obj)
    {
        if (obj is null)
            return false;
        if (obj is not User)
            return false;

        User user = (User)obj;
        if (user.Account == Account && user.Password.Trim() == Password.Trim())
            return true;
        return false;
    }

    public override int GetHashCode()
    {
        throw new NotImplementedException();
    }
}
